#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e5 + 5;

int n, m;
struct Node {
  int x, y, z;
  bool operator<(const Node& o) const {
    if (x != o.x) return x < o.x;
    if (y != o.y) return y > o.y;
    return z < o.z;
  }
} a[N];
int b[N], num;
void discrete() {
  rep(i, 1, n) b[i] = a[i].y;
  sort(b + 1, b + n + 1);
  num = unique(b + 1, b + n + 1) - b - 1;
  rep(i, 1, n) a[i].y = lower_bound(b + 1, b + num + 1, a[i].y) - b;
}
int d[N];
int bit[N];
int lowbit(int x) { return x & -x; }
void update(int x, int val) {
  if (d[x] >= val) return;
  d[x] = val;
  for (int i = x; i <= num; i += lowbit(i)) {
    bit[i] = max(bit[i], val);
  }
}
int query(int l, int r) {
  int res = 0;
  while (r >= l) {
    if (r - lowbit(r) + 1 >= l) {
      res = max(res, bit[r]);
      r -= lowbit(r);
    } else {
      res = max(res, d[r]);
      r--;
    }
  }
  return res;
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i].x;
  rep(i, 1, n) cin >> a[i].y;
  rep(i, 1, n) cin >> a[i].z;
  discrete();
  sort(a + 1, a + n + 1);
  int ans = 0;
  per(i, n, 1) {
    int mx = query(a[i].y + 1, num);
    if (mx > a[i].z) ans++;
    update(a[i].y, a[i].z);
  }
  cout << ans;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}